package 回溯.不熟;

import java.util.*;

/**
 * todo
 *
 * @author songZiHao
 * @version 1.0.0
 * @ClassName 拆分成最多数目的正偶数之和2178.java
 * @createTime 2023年08月02日 19:20:00
 */
public class 拆分成最多数目的正偶数之和2178 {
	public static void main(String[] args) {
		maximumEvenSplit(28);
	}

	static Set<Long> set = new HashSet<>();

	public static List<Long> maximumEvenSplit(long finalSum) {
		if (finalSum % 2 != 0) {
			return Collections.emptyList();
		}
		backTrace(2, finalSum);
		return new ArrayList<>(set);
	}

	public static void backTrace(long step, long left) {
		if (left == 0 || left-step < 0) {
			return;
		}
		set.add(step);
		backTrace(step+2, left-step);
		set.remove(step);

	}
}



